<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="design" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{designHome.managed ? 'Edit' : 'Add'} Design</f:facet>




            <s:decorate id="dateCreatedField" template="layout/edit.xhtml">
                <ui:define name="label">Date created</ui:define>
                <rich:calendar id="dateCreated"
                       required="true"
                          value="#{designHome.instance.dateCreated}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="descriptionField" template="layout/edit.xhtml">
                <ui:define name="label">Description</ui:define>
                <h:inputText id="description"
                          value="#{designHome.instance.description}">
                    <a:support event="onblur" reRender="descriptionField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="imageContentTypeField" template="layout/edit.xhtml">
                <ui:define name="label">Image content type</ui:define>
                <h:inputTextarea id="imageContentType"
                               cols="80"
                               rows="3"
                              value="#{designHome.instance.imageContentType}"/>
            </s:decorate>


            <s:decorate id="imageDataField" template="layout/edit.xhtml">
                <ui:define name="label">Image data</ui:define>
                <h:inputText id="imageData"
                          value="#{designHome.instance.imageData}">
                    <a:support event="onblur" reRender="imageDataField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="titleField" template="layout/edit.xhtml">
                <ui:define name="label">Title</ui:define>
                <h:inputTextarea id="title"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{designHome.instance.title}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{designHome.persist}"
                       disabled="#{!designHome.wired}"
                       rendered="#{!designHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{designHome.update}"
                       rendered="#{designHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{designHome.remove}"
                      immediate="true"
                       rendered="#{designHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Design.xhtml"
                rendered="#{designHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty designFrom ? 'DesignList' : designFrom}.xhtml"
                rendered="#{!designHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Company *" labelClass="required">
    <div class="association" id="companyParent">

        <h:outputText value="There is no company associated with this design."
                   rendered="#{designHome.instance.company == null}"/>

        <rich:dataTable var="_company"
                   value="#{designHome.instance.company}"
                rendered="#{designHome.instance.company != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="companyTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_company.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_company.name}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{designHome.instance.company != null ? 'Change' : 'Select'} company"
                       view="/CompanyList.xhtml">
                <f:param name="from" value="DesignEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
